
public class SynchQueue {
	NLLNode front = null;
	NLLNode rear = null;
	int numElements = 0;
	
	public synchronized boolean isEmpty() {
		return (numElements == 0);
	}
	public synchronized void enqueue(Object data) {
		if (isEmpty()) {
			front = new NLLNode(data, null);
			rear = front;
		} else {
			rear.setNext(new NLLNode(data, null));
			rear = rear.next;
		}
		numElements++;
	}
	public synchronized Object dequeue() {
		NLLNode bla = null;
		if (isEmpty()) {
			bla = front;
			front = null;
		} else {
			bla = front;
			front = front.getNext();
		}
		numElements--;
		return bla.data;
	}
	public synchronized int size() {
		return numElements;
	}
	public synchronized Object peekFront() {
		return front.data;
	}
	public synchronized Object peekRear() {
		return rear.data;
	}
}
class NLLNode {
	Object data = null;
	NLLNode next = null;
	NLLNode previous = null;
	public NLLNode() {
		data=null;
		next=null;
		previous=null;
	}
	public NLLNode(Object data, NLLNode next) {
		super();
		this.data = data;
		this.next = next;
	}
	public NLLNode(Object data, NLLNode next, NLLNode previous) {
		super();
		this.data = data;
		this.next = next;
		this.previous = previous;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public NLLNode getNext() {
		return next;
	}
	public void setNext(NLLNode next) {
		this.next = next;
	}
	public NLLNode getPrevious() {
		return previous;
	}
	public void setPrevious(NLLNode previous) {
		this.previous = previous;
	}
}
